<?php
define("EW_PAGE_ID", "view", TRUE); // Page ID
define("EW_TABLE_NAME", 'orders_movie', TRUE);
?>
<?php 
session_start(); // Initialize session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg50.php" ?>
<?php include "ewmysql50.php" ?>
<?php include "phpfn50.php" ?>
<?php include "orders_movieinfo.php" ?>
<?php include "userfn50.php" ?>
<?php include "usersinfo.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Open connection to the database
$conn = ew_Connect();
?>
<?php
$Security = new cAdvancedSecurity();
?>
<?php
if (!$Security->IsLoggedIn()) $Security->AutoLogin();
$Security->LoadCurrentUserLevel('orders_movie');
if (!$Security->IsLoggedIn()) {
	$Security->SaveLastUrl();
	Page_Terminate("login.php");
}
if (!$Security->CanView()) {
	$Security->SaveLastUrl();
	Page_Terminate("orders_movielist.php");
}
?>
<?php

// Common page loading event (in userfn*.php)
Page_Loading();
?>
<?php

// Page load event, used in current page
Page_Load();
?>
<?php
$orders_movie->Export = @$_GET["export"]; // Get export parameter
$sExport = $orders_movie->Export; // Get export parameter, used in header
$sExportFile = $orders_movie->TableVar; // Get export file, used in header
?>
<?php
if (@$_GET["id"] <> "") {
	$orders_movie->id->setQueryStringValue($_GET["id"]);
} else {
	Page_Terminate("orders_movielist.php"); // Return to list page
}

// Get action
if (@$_POST["a_view"] <> "") {
	$orders_movie->CurrentAction = $_POST["a_view"];
} else {
	$orders_movie->CurrentAction = "I"; // Display form
}
switch ($orders_movie->CurrentAction) {
	
	case "I": // Get a record to display				
		if (!LoadRow()) { // Load record based on key
			$_SESSION[EW_SESSION_MESSAGE] = "No records found"; // Set no record message
			Page_Terminate("orders_movielist.php"); // Return to list
		}
}

// Set return url
$orders_movie->setReturnUrl("orders_movieview.php");

// Render row
$orders_movie->RowType = EW_ROWTYPE_VIEW;
RenderRow();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--
var EW_PAGE_ID = "view"; // Page id
var EW_SHOW_HIGHLIGHT = "Show highlight"; 
var EW_HIDE_HIGHLIGHT = "Hide highlight";

//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->

</script>
<p><span class="phpmaker">View TABLE: orders movie
<br><br>
<a href="orders_movielist.php">Back to List</a>&nbsp;
<?php if ($Security->CanAdd()) { ?>
<a href="orders_movieadd.php">Add</a>&nbsp;
<?php } ?>
<?php if ($Security->CanEdit()) { ?>
<a href="<?php echo $orders_movie->EditUrl() ?>">Edit</a>&nbsp;
<?php } ?>
<?php if ($Security->CanAdd()) { ?>
<a href="<?php echo $orders_movie->CopyUrl() ?>">Copy</a>&nbsp;
<?php } ?>
<?php if ($Security->CanDelete()) { ?>
<a href="<?php echo $orders_movie->DeleteUrl() ?>">Delete</a>&nbsp;
<?php } ?>
</span>
</p>
<?php
if (@$_SESSION[EW_SESSION_MESSAGE] <> "") {
?>
<p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
<?php
	$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message
}
?>
<p>
<form>
<table class="ewTable">
	<tr class="ewTableRow">
		<td class="ewTableHeader">ID</td>
		<td<?php echo $orders_movie->id->CellAttributes() ?>>
<div<?php echo $orders_movie->id->ViewAttributes() ?>><?php echo $orders_movie->id->ViewValue ?></div>
</td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="ewTableHeader">Bill</td>
		<td<?php echo $orders_movie->bill->CellAttributes() ?>>
<div<?php echo $orders_movie->bill->ViewAttributes() ?>><?php echo $orders_movie->bill->ViewValue ?></div>
</td>
	</tr>
	<tr class="ewTableRow">
		<td class="ewTableHeader">Fullname</td>
		<td<?php echo $orders_movie->fullname->CellAttributes() ?>>
<div<?php echo $orders_movie->fullname->ViewAttributes() ?>><?php echo $orders_movie->fullname->ViewValue ?></div>
</td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="ewTableHeader">Email</td>
		<td<?php echo $orders_movie->email->CellAttributes() ?>>
<div<?php echo $orders_movie->email->ViewAttributes() ?>><?php echo $orders_movie->email->ViewValue ?></div>
</td>
	</tr>
	<tr class="ewTableRow">
		<td class="ewTableHeader">Address</td>
		<td<?php echo $orders_movie->address->CellAttributes() ?>>
<div<?php echo $orders_movie->address->ViewAttributes() ?>><?php echo $orders_movie->address->ViewValue ?></div>
</td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="ewTableHeader">Telephone</td>
		<td<?php echo $orders_movie->tel->CellAttributes() ?>>
<div<?php echo $orders_movie->tel->ViewAttributes() ?>><?php echo $orders_movie->tel->ViewValue ?></div>
</td>
	</tr>
	<tr class="ewTableRow">
		<td class="ewTableHeader">Note</td>
		<td<?php echo $orders_movie->note->CellAttributes() ?>>
<div<?php echo $orders_movie->note->ViewAttributes() ?>><?php echo $orders_movie->note->ViewValue ?></div>
</td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="ewTableHeader">Mv Id</td>
		<td<?php echo $orders_movie->mv_id->CellAttributes() ?>>
<div<?php echo $orders_movie->mv_id->ViewAttributes() ?>><?php echo $orders_movie->mv_id->ViewValue ?></div>
</td>
	</tr>
	<tr class="ewTableRow">
		<td class="ewTableHeader">Title</td>
		<td<?php echo $orders_movie->pro_title->CellAttributes() ?>>
<div<?php echo $orders_movie->pro_title->ViewAttributes() ?>><?php echo $orders_movie->pro_title->ViewValue ?></div>
</td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="ewTableHeader">Quantity</td>
		<td<?php echo $orders_movie->pro_quantity->CellAttributes() ?>>
<div<?php echo $orders_movie->pro_quantity->ViewAttributes() ?>><?php echo $orders_movie->pro_quantity->ViewValue ?></div>
</td>
	</tr>
	<tr class="ewTableRow">
		<td class="ewTableHeader">Totalmoney</td>
		<td<?php echo $orders_movie->pro_totalmoney->CellAttributes() ?>>
<div<?php echo $orders_movie->pro_totalmoney->ViewAttributes() ?>><?php echo $orders_movie->pro_totalmoney->ViewValue ?></div>
</td>
	</tr>
	<tr class="ewTableAltRow">
		<td class="ewTableHeader">Date Add</td>
		<td<?php echo $orders_movie->dateadd->CellAttributes() ?>>
<div<?php echo $orders_movie->dateadd->ViewAttributes() ?>><?php echo $orders_movie->dateadd->ViewValue ?></div>
</td>
	</tr>
	<tr class="ewTableRow">
		<td class="ewTableHeader">Status</td>
		<td<?php echo $orders_movie->status->CellAttributes() ?>>
<div<?php echo $orders_movie->status->ViewAttributes() ?>><?php echo $orders_movie->status->ViewValue ?></div>
</td>
	</tr>
</table>
</form>
<p>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php include "footer.php" ?>
<?php

// If control is passed here, simply terminate the page without redirect
Page_Terminate();

// -----------------------------------------------------------------
//  Subroutine Page_Terminate
//  - called when exit page
//  - clean up connection and objects
//  - if url specified, redirect to url, otherwise end response
function Page_Terminate($url = "") {
	global $conn;

	// Page unload event, used in current page
	Page_Unload();

	// Global page unloaded event (in userfn*.php)
	Page_Unloaded();

	 // Close Connection
	$conn->Close();

	// Go to url if specified
	if ($url <> "") {
		ob_end_clean();
		header("Location: $url");
	}
	exit();
}
?>
<?php

// Load row based on key values
function LoadRow() {
	global $conn, $Security, $orders_movie;
	$sFilter = $orders_movie->SqlKeyFilter();	
	if (!is_numeric($orders_movie->id->CurrentValue)) {
		return FALSE; // Invalid key, exit
	}
	$sFilter = str_replace("@id@", ew_AdjustSql($orders_movie->id->CurrentValue), $sFilter); // Replace key value
	
	// Call Row Selecting event
	$orders_movie->Row_Selecting($sFilter);

	// Load sql based on filter
	$orders_movie->CurrentFilter = $sFilter;	
	$sSql = $orders_movie->SQL();

	if ($rs = $conn->Execute($sSql)) {
		if ($rs->EOF) {
			$LoadRow = FALSE;
		} else {
			$LoadRow = TRUE;
			$rs->MoveFirst();
			LoadRowValues($rs); // Load row values

			// Call Row Selected event
			$orders_movie->Row_Selected($rs);
		}
		$rs->Close();
	} else {
		$LoadRow = FALSE;
	}
	return $LoadRow;
}

// Load row values from recordset
function LoadRowValues(&$rs) {
	global $orders_movie;
	$orders_movie->id->setDbValue($rs->fields('id'));
	$orders_movie->bill->setDbValue($rs->fields('bill'));
	$orders_movie->fullname->setDbValue($rs->fields('fullname'));
	$orders_movie->email->setDbValue($rs->fields('email'));
	$orders_movie->address->setDbValue($rs->fields('address'));
	$orders_movie->tel->setDbValue($rs->fields('tel'));
	$orders_movie->note->setDbValue($rs->fields('note'));
	$orders_movie->mv_id->setDbValue($rs->fields('mv_id'));
	$orders_movie->pro_title->setDbValue($rs->fields('pro_title'));
	$orders_movie->pro_quantity->setDbValue($rs->fields('pro_quantity'));
	$orders_movie->pro_totalmoney->setDbValue($rs->fields('pro_totalmoney'));
	$orders_movie->dateadd->setDbValue($rs->fields('dateadd'));
	$orders_movie->status->setDbValue($rs->fields('status'));
}
?>
<?php

// Render row values based on field settings
function RenderRow() {
	global $conn, $Security, $orders_movie;

	// Call Row Rendering event
	$orders_movie->Row_Rendering();

	// Common render codes for all row types
	// id

	$orders_movie->id->CellCssStyle = "";
	$orders_movie->id->CellCssClass = "";

	// bill
	$orders_movie->bill->CellCssStyle = "";
	$orders_movie->bill->CellCssClass = "";

	// fullname
	$orders_movie->fullname->CellCssStyle = "";
	$orders_movie->fullname->CellCssClass = "";

	// email
	$orders_movie->email->CellCssStyle = "";
	$orders_movie->email->CellCssClass = "";

	// address
	$orders_movie->address->CellCssStyle = "";
	$orders_movie->address->CellCssClass = "";

	// tel
	$orders_movie->tel->CellCssStyle = "";
	$orders_movie->tel->CellCssClass = "";

	// note
	$orders_movie->note->CellCssStyle = "";
	$orders_movie->note->CellCssClass = "";

	// mv_id
	$orders_movie->mv_id->CellCssStyle = "";
	$orders_movie->mv_id->CellCssClass = "";

	// pro_title
	$orders_movie->pro_title->CellCssStyle = "";
	$orders_movie->pro_title->CellCssClass = "";

	// pro_quantity
	$orders_movie->pro_quantity->CellCssStyle = "";
	$orders_movie->pro_quantity->CellCssClass = "";

	// pro_totalmoney
	$orders_movie->pro_totalmoney->CellCssStyle = "";
	$orders_movie->pro_totalmoney->CellCssClass = "";

	// dateadd
	$orders_movie->dateadd->CellCssStyle = "";
	$orders_movie->dateadd->CellCssClass = "";

	// status
	$orders_movie->status->CellCssStyle = "";
	$orders_movie->status->CellCssClass = "";
	if ($orders_movie->RowType == EW_ROWTYPE_VIEW) { // View row

		// id
		$orders_movie->id->ViewValue = $orders_movie->id->CurrentValue;
		$orders_movie->id->CssStyle = "";
		$orders_movie->id->CssClass = "";
		$orders_movie->id->ViewCustomAttributes = "";

		// bill
		$orders_movie->bill->ViewValue = $orders_movie->bill->CurrentValue;
		$orders_movie->bill->CssStyle = "";
		$orders_movie->bill->CssClass = "";
		$orders_movie->bill->ViewCustomAttributes = "";

		// fullname
		$orders_movie->fullname->ViewValue = $orders_movie->fullname->CurrentValue;
		$orders_movie->fullname->CssStyle = "";
		$orders_movie->fullname->CssClass = "";
		$orders_movie->fullname->ViewCustomAttributes = "";

		// email
		$orders_movie->email->ViewValue = $orders_movie->email->CurrentValue;
		$orders_movie->email->CssStyle = "";
		$orders_movie->email->CssClass = "";
		$orders_movie->email->ViewCustomAttributes = "";

		// address
		$orders_movie->address->ViewValue = $orders_movie->address->CurrentValue;
		$orders_movie->address->CssStyle = "";
		$orders_movie->address->CssClass = "";
		$orders_movie->address->ViewCustomAttributes = "";

		// tel
		$orders_movie->tel->ViewValue = $orders_movie->tel->CurrentValue;
		$orders_movie->tel->CssStyle = "";
		$orders_movie->tel->CssClass = "";
		$orders_movie->tel->ViewCustomAttributes = "";

		// note
		$orders_movie->note->ViewValue = $orders_movie->note->CurrentValue;
		if (!is_null($orders_movie->note->ViewValue)) $orders_movie->note->ViewValue = str_replace("\n", "<br>", $orders_movie->note->ViewValue); 
		$orders_movie->note->CssStyle = "";
		$orders_movie->note->CssClass = "";
		$orders_movie->note->ViewCustomAttributes = "";

		// mv_id
		$orders_movie->mv_id->ViewValue = $orders_movie->mv_id->CurrentValue;
		$orders_movie->mv_id->CssStyle = "";
		$orders_movie->mv_id->CssClass = "";
		$orders_movie->mv_id->ViewCustomAttributes = "";

		// pro_title
		$orders_movie->pro_title->ViewValue = $orders_movie->pro_title->CurrentValue;
		$orders_movie->pro_title->CssStyle = "";
		$orders_movie->pro_title->CssClass = "";
		$orders_movie->pro_title->ViewCustomAttributes = "";

		// pro_quantity
		$orders_movie->pro_quantity->ViewValue = $orders_movie->pro_quantity->CurrentValue;
		$orders_movie->pro_quantity->CssStyle = "";
		$orders_movie->pro_quantity->CssClass = "";
		$orders_movie->pro_quantity->ViewCustomAttributes = "";

		// pro_totalmoney
		$orders_movie->pro_totalmoney->ViewValue = $orders_movie->pro_totalmoney->CurrentValue;
		$orders_movie->pro_totalmoney->CssStyle = "";
		$orders_movie->pro_totalmoney->CssClass = "";
		$orders_movie->pro_totalmoney->ViewCustomAttributes = "";

		// dateadd
		$orders_movie->dateadd->ViewValue = $orders_movie->dateadd->CurrentValue;
		$orders_movie->dateadd->ViewValue = ew_FormatDateTime($orders_movie->dateadd->ViewValue, 7);
		$orders_movie->dateadd->CssStyle = "";
		$orders_movie->dateadd->CssClass = "";
		$orders_movie->dateadd->ViewCustomAttributes = "";

		// status
		if (strval($orders_movie->status->CurrentValue) <> "") {
			$orders_movie->status->ViewValue = "";
			$arwrk = explode(",", strval($orders_movie->status->CurrentValue));
			for ($ari = 0; $ari < count($arwrk); $ari++) {
				switch (trim($arwrk[$ari])) {
					case "1":
						$orders_movie->status->ViewValue .= "Active";
						break;
					default:
						$orders_movie->status->ViewValue .= trim($arwrk[$ari]);
				}
				if ($ari < count($arwrk)-1) $orders_movie->status->ViewValue .= ew_ViewOptionSeparator($ari);
			}
		} else {
			$orders_movie->status->ViewValue = NULL;
		}
		$orders_movie->status->CssStyle = "";
		$orders_movie->status->CssClass = "";
		$orders_movie->status->ViewCustomAttributes = "";

		// id
		$orders_movie->id->HrefValue = "";

		// bill
		$orders_movie->bill->HrefValue = "";

		// fullname
		$orders_movie->fullname->HrefValue = "";

		// email
		$orders_movie->email->HrefValue = "";

		// address
		$orders_movie->address->HrefValue = "";

		// tel
		$orders_movie->tel->HrefValue = "";

		// note
		$orders_movie->note->HrefValue = "";

		// mv_id
		$orders_movie->mv_id->HrefValue = "";

		// pro_title
		$orders_movie->pro_title->HrefValue = "";

		// pro_quantity
		$orders_movie->pro_quantity->HrefValue = "";

		// pro_totalmoney
		$orders_movie->pro_totalmoney->HrefValue = "";

		// dateadd
		$orders_movie->dateadd->HrefValue = "";

		// status
		$orders_movie->status->HrefValue = "";
	} elseif ($orders_movie->RowType == EW_ROWTYPE_ADD) { // Add row
	} elseif ($orders_movie->RowType == EW_ROWTYPE_EDIT) { // Edit row
	} elseif ($orders_movie->RowType == EW_ROWTYPE_SEARCH) { // Search row
	}

	// Call Row Rendered event
	$orders_movie->Row_Rendered();
}
?>
<?php

// Set up Starting Record parameters based on Pager Navigation
function SetUpStartRec() {
	global $nDisplayRecs, $nStartRec, $nTotalRecs, $nPageNo, $orders_movie;
	if ($nDisplayRecs == 0) return;

	// Check for a START parameter
	if (@$_GET[EW_TABLE_START_REC] <> "") {
		$nStartRec = $_GET[EW_TABLE_START_REC];
		$orders_movie->setStartRecordNumber($nStartRec);
	} elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
		$nPageNo = $_GET[EW_TABLE_PAGE_NO];
		if (is_numeric($nPageNo)) {
			$nStartRec = ($nPageNo-1)*$nDisplayRecs+1;
			if ($nStartRec <= 0) {
				$nStartRec = 1;
			} elseif ($nStartRec >= intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1) {
				$nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1;
			}
			$orders_movie->setStartRecordNumber($nStartRec);
		} else {
			$nStartRec = $orders_movie->getStartRecordNumber();
		}
	} else {
		$nStartRec = $orders_movie->getStartRecordNumber();
	}

	// Check if correct start record counter
	if (!is_numeric($nStartRec) || $nStartRec == "") { // Avoid invalid start record counter
		$nStartRec = 1; // Reset start record counter
		$orders_movie->setStartRecordNumber($nStartRec);
	} elseif (intval($nStartRec) > intval($nTotalRecs)) { // Avoid starting record > total records
		$nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to last page first record
		$orders_movie->setStartRecordNumber($nStartRec);
	} elseif (($nStartRec-1) % $nDisplayRecs <> 0) {
		$nStartRec = intval(($nStartRec-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to page boundary
		$orders_movie->setStartRecordNumber($nStartRec);
	}
}
?>
<?php

// Page Load event
function Page_Load() {

	//echo "Page Load";
}

// Page Unload event
function Page_Unload() {

	//echo "Page Unload";
}
?>
